import { RouteRecordRaw } from 'vue-router'
import Layout from '../Layout.vue'

import { defineAsyncComponent } from 'vue'
const _import = (path: string) => defineAsyncComponent(() => import(`../views/${path}/index.vue`));
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    children: [
      {
        path: 'home',
        name: 'home',
        component: _import('home'),
      },
      {
        path: '/about',
        name: 'about',
        component: _import('about'),
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: defineAsyncComponent(() => import(`../views/login/index.vue`))
  },
  {
    path: '/:pathMatch(.*)',
    name: 'Error',
    component: _import('error')
  }
];

export { routes }